package com.hibernate.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.javacommon.base.BaseEntity;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;

/**
 * 
 */

@Entity
@Table(name = "REPORT_PEOPLE_AREA")
public class ReportPeopleArea extends BaseEntity implements java.io.Serializable{
	private static final long serialVersionUID = 5454155825314635342L;
	
	//alias
	public static final String TABLE_ALIAS = "人群属性分析-地区分布";
	public static final String ALIAS_ID = "ID";
	public static final String ALIAS_PROVINCE_ID = "省份ID";
	public static final String ALIAS_AD_OWNER_ID = "广告客户ID";
	public static final String ALIAS_ACCESS_PV = "访问次数";
	public static final String ALIAS_ACCESS_UV = "访问人数";
	public static final String ALIAS_CONVERT_PV = "转换次数";
	public static final String ALIAS_CONVERT_UV = "转换人数";
	public static final String ALIAS_LOG_DATE = "日期";
	
	//date formats
	

	//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
	//columns START
    /**
     * ID       db_column: ID 
     */ 	
	
	private Long id;
    /**
     * 省份ID       db_column: PROVINCE_ID 
     */ 	
	@NotNull 
	private Long provinceId;
    /**
     * 广告客户ID       db_column: AD_OWNER_ID 
     */ 	
	@NotNull 
	private Long adOwnerId;
    /**
     * 访问次数       db_column: ACCESS_PV 
     */ 	
	@NotNull 
	private Long accessPv;
    /**
     * 访问人数       db_column: ACCESS_UV 
     */ 	
	@NotNull 
	private Long accessUv;
    /**
     * 转换次数       db_column: CONVERT_PV 
     */ 	
	@NotNull 
	private Long convertPv;
    /**
     * 转换人数       db_column: CONVERT_UV 
     */ 	
	@NotNull 
	private Long convertUv;
    /**
     * 日期       db_column: LOG_DATE 
     */ 	
	@NotBlank @Length(max=10)
	private java.lang.String logDate;
	private Long poid;
	
	//columns END


	public ReportPeopleArea(){
	}

	public ReportPeopleArea(
		Long id
	){
		this.id = id;
	}

	

	public void setId(Long value) {
		this.id = value;
	}
	
	@Id
	@GeneratedValue(generator = "paymentableGenerator")       
	@GenericGenerator(name = "paymentableGenerator", strategy = "native") 
	@Column(name = "ID", unique = true, nullable = false, insertable = true, updatable = true, length = 20)
	public Long getId() {
		return this.id;
	}
	
	@Column(name = "PROVINCE_ID", unique = false, nullable = false, insertable = true, updatable = true, length = 20)
	public Long getProvinceId() {
		return this.provinceId;
	}
	
	public void setProvinceId(Long value) {
		this.provinceId = value;
	}
	
	@Column(name = "AD_OWNER_ID", unique = false, nullable = false, insertable = true, updatable = true, length = 20)
	public Long getAdOwnerId() {
		return this.adOwnerId;
	}
	
	public void setAdOwnerId(Long value) {
		this.adOwnerId = value;
	}
	
	@Column(name = "ACCESS_PV", unique = false, nullable = false, insertable = true, updatable = true, length = 20)
	public Long getAccessPv() {
		return this.accessPv;
	}
	
	public void setAccessPv(Long value) {
		this.accessPv = value;
	}
	
	@Column(name = "ACCESS_UV", unique = false, nullable = false, insertable = true, updatable = true, length = 20)
	public Long getAccessUv() {
		return this.accessUv;
	}
	
	public void setAccessUv(Long value) {
		this.accessUv = value;
	}
	
	@Column(name = "CONVERT_PV", unique = false, nullable = false, insertable = true, updatable = true, length = 20)
	public Long getConvertPv() {
		return this.convertPv;
	}
	
	public void setConvertPv(Long value) {
		this.convertPv = value;
	}
	
	@Column(name = "CONVERT_UV", unique = false, nullable = false, insertable = true, updatable = true, length = 20)
	public Long getConvertUv() {
		return this.convertUv;
	}
	
	public void setConvertUv(Long value) {
		this.convertUv = value;
	}
	
	@Column(name = "LOG_DATE", unique = false, nullable = false, insertable = true, updatable = true, length = 10)
	public java.lang.String getLogDate() {
		return this.logDate;
	}
	
	public void setLogDate(java.lang.String value) {
		this.logDate = value;
	}
	
	@Column(name = "POID", unique = false, nullable = true, insertable = true, updatable = true, length = 20)
	public Long getPoid() {
		return this.poid;
	}
	
	public void setPoid(Long value) {
		this.poid = value;
	}
	
	
	private TipRegionZoneCn province;
	public void setProvince(TipRegionZoneCn province){
		this.province = province;
	}
	
	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumns({
		@JoinColumn(name = "POID",nullable = false, insertable = false, updatable = false) 
	})
	public TipRegionZoneCn getProvince() {
		return province;
	}
	
	private AdOwner adOwner;
	public void setAdOwner(AdOwner adOwner){
		this.adOwner = adOwner;
	}
	
	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumns({
		@JoinColumn(name = "AD_OWNER_ID",nullable = false, insertable = false, updatable = false) 
	})
	public AdOwner getAdOwner() {
		return adOwner;
	}

	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
			.append("Id",getId())
			.append("ProvinceId",getProvinceId())
			.append("AdOwnerId",getAdOwnerId())
			.append("AccessPv",getAccessPv())
			.append("AccessUv",getAccessUv())
			.append("ConvertPv",getConvertPv())
			.append("ConvertUv",getConvertUv())
			.append("LogDate",getLogDate())
			.toString();
	}
	
	public int hashCode() {
		return new HashCodeBuilder()
			.append(getId())
			.toHashCode();
	}
	
	public boolean equals(Object obj) {
		if(obj instanceof ReportPeopleArea == false) return false;
		if(this == obj) return true;
		ReportPeopleArea other = (ReportPeopleArea)obj;
		return new EqualsBuilder()
			.append(getId(),other.getId())
			.isEquals();
	}
	@Transient
	@Override
	public String getTarget() {
		// TODO Auto-generated method stub
		return null;
	}
	@Transient
	@Override
	public Long getTargetId() {
		// TODO Auto-generated method stub
		return null;
	}
	@Transient
	@Override
	public String getTargetName() {
		// TODO Auto-generated method stub
		return null;
	}
}

